import { ArticleComment } from './../../modules/article/article.comment.entity';
import { ArticleService } from './../../modules/article/article.service';
import { Controller, Get, Param, Post, Body } from '@nestjs/common';

@Controller('miao/article')
export class ArticleController {

  constructor(
    private readonly articleService: ArticleService,
  ){}


  @Get('list')
  async list(){
    return await this.articleService.list()
  }

  @Get(':id')
  async index(
    @Param('id') _id: string
  ){
    return await this.articleService.get(parseInt(_id))
  }

  @Get(':id/comment/list')
  async commentList(
    @Param('id') _id: string
  ){
    return await this.articleService.getCommentList(parseInt(_id))
  }

  @Post(':id/comment')
  async addComment(
    @Param('id') _id: string,
    @Body() body: ArticleComment
  ){
    return await this.articleService.addComment(parseInt(_id), body)
  }

}
